#include <iostream>
#include <fstream>
#include <vector>
#include <chrono>

void sort_nums(std::vector<int>& data) {
    bool flag = true;
    while (flag) {
        flag = false;
        for (size_t i = 0; i < data.size() - 1; ++i) {
            if (data[i] > data[i + 1]) {
                std::swap(data[i], data[i + 1]);
                flag = true;
            }
        }
    }
}

std::vector<int> read_f(const std::string& file) {
    std::ifstream input(file);
    std::vector<int> data;
    int num;
    while (input >> num) {
        data.push_back(num);
    }
    return data;
}

void time_m(const std::string& mt) {
    std::vector<int> step_1 = read_f(mt);
    auto time_start = std::chrono::high_resolution_clock::now();
    sort_nums(step_1);
    auto time_finish = std::chrono::high_resolution_clock::now();
    std::cout << mt << " " << std::chrono::duration_cast<std::chrono::milliseconds>(time_finish - time_start).count() << " milliseconds" << std::endl;
}

int main() {
    time_m("m1_sorted.txt");
    time_m("m2_reverse.txt");
    time_m("m3_shuffle.txt");
    return 0;
}
